$scriptDir = (split-path $myinvocation.mycommand.path -parent)

$dir = $env:windir + "\system32\inetsrv"

Set-Location $dir
$apps = .\appcmd.exe list config /section:system.webServer/fastCgi

$foundImpersonate = $FALSE;

$phpXml = [xml] $apps;
$phpDir = [System.IO.Path]::GetDirectoryName($phpXml."system.WebServer".fastCgi.application.fullPath);

Set-Location $scriptDir

if ($phpDir -ne "")
{	
	$phpIni = [System.IO.Path]::Combine($phpDir, "php.ini");
    
    $value = .\Get-PrivateProfileString.ps1 "$phpIni" PHP fastcgi.impersonate

	if ($value -like "*")
    {
        .\Set-PrivateProfileString.ps1 "$phpIni" PHP fastcgi.impersonate 0
        
        $value = .\Get-PrivateProfileString.ps1 "$phpIni" PHP fastcgi.impersonate
        
        if ($value -eq "0")
        {
            .\Set-PrivateProfileString.ps1 "$phpIni" PHP fastcgi.impersonate 1
            $foundImpersonate = $TRUE;
        }             
    }	
}

$foundImpersonate